package edu.xidian.onlinedocument.views;

import edu.xidian.onlinedocument.views.groups.DataGroupA;
import edu.xidian.onlinedocument.views.groups.DataGroupB;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.lang.reflect.Field;

/**
 * 通用输入类，规定前端发给后端的json报文的格式
 * 已遗弃，token直接放在http请求头中
 */
@Data
@NoArgsConstructor      // 生成一个无参数的构造方法
@AllArgsConstructor     // 生成一个全参数的构造方法
public class Request {
    @NotBlank(groups = DataGroupA.class)
    @Pattern(regexp = "^[0-9a-zA-Z._-]+$", groups = DataGroupA.class)
    private String token;

    @NotNull(groups = DataGroupB.class)
    private Object data;

    public Request(String token){
        this.token = token;
        data = null;
    }

    public String getClassTokenName(){
        return "token";
    }
}
